package com.mes.production.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.mes.common.core.utils.poi.ExcelUtil;
import com.mes.common.core.web.controller.BaseController;
import com.mes.common.core.web.domain.AjaxResult;
import com.mes.common.core.web.page.TableDataInfo;
import com.mes.common.log.annotation.Log;
import com.mes.common.log.enums.BusinessType;
import com.mes.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mes.production.domain.ProductionReport;
import com.mes.production.service.IProductionReportService;

/**
 * 生产报工Controller
 * 
 * @author ruoyi
 * @date 2025-02-27
 */
@RestController
@RequestMapping("/production/productionReport")
public class ProductionReportController extends BaseController
{
    @Autowired
    private IProductionReportService productionReportService;

    /**
     * 查询生产报工列表
     */
    @RequiresPermissions("production:productionReport:list")
    @GetMapping("/list")
    public TableDataInfo list(ProductionReport productionReport)
    {
        startPage();
        List<ProductionReport> list = productionReportService.selectProductionReportList(productionReport);
        return getDataTable(list);
    }

    /**
     * 导出生产报工列表
     */
    @RequiresPermissions("production:productionReport:export")
    @Log(title = "生产报工", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductionReport productionReport)
    {
        List<ProductionReport> list = productionReportService.selectProductionReportList(productionReport);
        ExcelUtil<ProductionReport> util = new ExcelUtil<ProductionReport>(ProductionReport.class);
        util.exportExcel(response, list, "生产报工数据");
    }

    /**
     * 获取生产报工详细信息
     */
    @RequiresPermissions("production:productionReport:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(productionReportService.selectProductionReportById(id));
    }

    /**
     * 新增生产报工
     */
    @RequiresPermissions("production:productionReport:add")
    @Log(title = "生产报工", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductionReport productionReport)
    {
        return toAjax(productionReportService.insertProductionReport(productionReport));
    }

    /**
     * 修改生产报工
     */
    @RequiresPermissions("production:productionReport:edit")
    @Log(title = "生产报工", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductionReport productionReport)
    {
        return toAjax(productionReportService.updateProductionReport(productionReport));
    }

    /**
     * 删除生产报工
     */
    @RequiresPermissions("production:productionReport:remove")
    @Log(title = "生产报工", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(productionReportService.deleteProductionReportByIds(ids));
    }
}
